34 typedef typename std::map<TimeStamp, T>::iterator
Iterator;
107 const double& _time_tolerance);
115 const double& _time_tolerance1,
117 const double& _time_tolerance2);
131 const double& _time_tolerance)
const
135 bool prev_exists = (post != container_.begin());
136 bool post_exists = (post != container_.end());
138 bool post_ok = post_exists && checkTimeTolerance(post->first, _time_stamp, _time_tolerance);
144 bool prev_ok = checkTimeTolerance(prev->first, _time_stamp, _time_tolerance);
146 if (prev_ok && !post_ok)
149 else if (!prev_ok && post_ok)
152 else if (prev_ok && post_ok)
154 if (std::fabs(post->first - _time_stamp) < std::fabs(prev->first - _time_stamp))
163 return container_.end();
168 const double& _time_tolerance)
172 bool prev_exists = (post != container_.begin());
173 bool post_exists = (post != container_.end());
175 bool post_ok = post_exists && checkTimeTolerance(post->first, _time_stamp, _time_tolerance);
181 bool prev_ok = checkTimeTolerance(prev->first, _time_stamp, _time_tolerance);
183 if (prev_ok && !post_ok)
186 else if (!prev_ok && post_ok)
189 else if (prev_ok && post_ok)
191 if (std::fabs(post->first - _time_stamp) < std::fabs(prev->first - _time_stamp))
200 return container_.end();
206 if (container_.empty())
return T();
208 auto it = selectIterator(_time_stamp, _time_tolerance);
212 if (it != container_.end())
224 if (container_.empty())
return T();
228 if (container_.begin()->first < _time_stamp)
return container_.begin()->second;
231 if (checkTimeTolerance(container_.begin()->first, _time_stamp, _time_tolerance))
return container_.begin()->second;
241 if (container_.empty())
return T();
245 if (container_.rbegin()->first > _time_stamp)
return container_.rbegin()->second;
248 if (checkTimeTolerance(container_.rbegin()->first, _time_stamp, _time_tolerance))
249 return container_.rbegin()->second;
259 if (container_.empty())
return T();
262 return container_.begin()->second;
269 if (container_.empty())
return T();
272 return container_.rbegin()->second;
278 container_.emplace(_time_stamp, _element);
302 return container_.empty();
308 return container_.size();
315 container_.erase(container_.begin(), post);
322 container_.erase(container_.begin(), post);
327 const double& _time_tolerance1,
329 const double& _time_tolerance2)
331 double time_diff = std::fabs(_time_stamp1 - _time_stamp2);
332 double time_tol = std::min(_time_tolerance1, _time_tolerance2);
333 bool pass = time_diff <= time_tol;
340 const double& _time_tolerance)
342 double time_diff = std::fabs(_time_stamp1 - _time_stamp2);
343 bool pass = time_diff <= _time_tolerance;
356 void emplace(FrameBasePtr _frm);
364 void emplace(CaptureBasePtr _cap);
Buffer of Captures.
Definition: buffer.h:362
void emplace(CaptureBasePtr _cap)
Definition: buffer.cpp:30
Buffer of Frames.
Definition: buffer.h:354
void emplace(FrameBasePtr _frm)
Definition: buffer.cpp:25
Buffer of VectorComposite.
Definition: buffer.h:370
Buffer for arbitrary type objects.
Definition: buffer.h:32
static bool doubleCheckTimeTolerance(const TimeStamp &_time_stamp1, const double &_time_tolerance1, const TimeStamp &_time_stamp2, const double &_time_tolerance2)
Check time tolerance.
Definition: buffer.h:326
SizeStd size(void) const
Buffer size.
Definition: buffer.h:306
std::map< TimeStamp, T >::iterator Iterator
Definition: buffer.h:34
void clear()
Clear the buffer.
Definition: buffer.h:294
const std::map< TimeStamp, T > & getContainer() const
returns the container with elements of the buffer
Definition: buffer.h:282
void removeUpTo(const TimeStamp &_time_stamp)
Remove all elements in the buffer with a time stamp older than the specified.
Definition: buffer.h:312
std::map< TimeStamp, T >::const_iterator ConstIterator
Definition: buffer.h:35
void emplace(const TimeStamp &_time_stamp, const T &_element)
Add a element to the buffer.
Definition: buffer.h:276
Iterator selectIterator(const TimeStamp &_time_stamp, const double &_time_tolerance)
Definition: buffer.h:167
T select(const TimeStamp &_time_stamp, const double &_time_tolerance) const
Select an element from the buffer.
Definition: buffer.h:204
T selectFirst() const
Definition: buffer.h:256
Buffer()
Definition: buffer.h:37
std::map< TimeStamp, T > & getContainer()
Definition: buffer.h:288
T selectLast() const
Definition: buffer.h:266
static bool checkTimeTolerance(const TimeStamp &_time_stamp1, const TimeStamp &_time_stamp2, const double &_time_tolerance)
Check time tolerance.
Definition: buffer.h:338
T selectLastAfter(const TimeStamp &_time_stamp, const double &_time_tolerance) const
Definition: buffer.h:238
~Buffer(void)
Definition: buffer.h:38
ConstIterator selectIterator(const TimeStamp &_time_stamp, const double &_time_tolerance) const
Select an element iterator from the buffer.
Definition: buffer.h:130
void removeUpToLower(const TimeStamp &_time_stamp)
Remove all elements in the buffer with a time stamp older than the specified.
Definition: buffer.h:319
bool empty() const
is the buffer empty ?
Definition: buffer.h:300
T selectFirstBefore(const TimeStamp &_time_stamp, const double &_time_tolerance) const
Definition: buffer.h:221
std::map< TimeStamp, T > container_
Definition: buffer.h:120
TimeStamp implements basic functionalities for time stamps.
Definition: time_stamp.h:39
Definition: vector_composite.h:27
Definition: capture_base.h:23
std::size_t SizeStd
Other containers size type for the Wolf project.
Definition: wolf.h:66